get rid of more unneeded const_cast.
authortsteven4 <tsteven4@gmail.com>
Sun, 1 Jul 2018 14:45:33 +0000 (08:45 -0600)
committertsteven4 <tsteven4@gmail.com>
Sun, 1 Jul 2018 14:45:33 +0000 (08:45 -0600)
compegps.cc
csv_util.cc
vecs.cc

index 74be6fa81bc5e7c9ba8a1fd3b30b20d7b83ed39e..362df191a2d56d202b27b0eb2d0e8fe5de195637 100644 (file)
@@ -78,8 +78,8 @@ static int snlen;
 static int radius;
 static int input_datum;
 
-static route_head* curr_track;
-static route_head* curr_route;
+static const route_head* curr_track;
+static const route_head* curr_route;
 
 /* placeholders for options */
 
@@ -514,7 +514,7 @@ write_waypt_cb(const Waypoint* wpt)
 static void
 write_route_hdr_cb(const route_head* rte)
 {
-  curr_route = const_cast<route_head*>(rte);
+  curr_route = rte;
   curr_index++;
   if (curr_index != target_index) {
     return;
@@ -540,7 +540,7 @@ static void
 write_track_hdr_cb(const route_head* trk)
 {
   track_info_flag = 0;
-  curr_track = const_cast<route_head*>(trk);
+  curr_track = trk;
 
   curr_index++;
   if (curr_index != target_index) {
index 439f6f191c18d25fdec7a1eb606747b200e645dd..6bfcc9349daf9d64b62c81f0493ff6b1fc118f5f 100644 (file)
@@ -480,7 +480,7 @@ human_to_dec(const char* instr, double* outlat, double* outlon, int which)
   const char* cur;
   double* numres = unk;
   int numind = 0;
-  char* buff;
+  char* buff = nullptr;
 
   if (strchr(instr, ',') != nullptr) {
     char* c;
@@ -488,12 +488,11 @@ human_to_dec(const char* instr, double* outlat, double* outlon, int which)
     while ((c = strchr(buff, ','))) {
       *c = '.';
     }
+    cur = buff;
   } else {
-    buff = const_cast<char*>(instr);
+    cur = instr;
   }
 
-  cur = buff;
-
   while (cur && *cur) {
     switch (*cur) {
     case 'n':
@@ -626,7 +625,7 @@ human_to_dec(const char* instr, double* outlat, double* outlon, int which)
       *outlon *= lonsign;
     }
   }
-  if (buff != instr) {
+  if (buff) {
     xfree(buff);
   }
 }
diff --git a/vecs.cc b/vecs.cc
index 5417f1af370e05d2e3d8502a89e94363568a4a96..a665d7cb383e11adefbc727f49d7d63c990c5022 100644 (file)
--- a/vecs.cc
+++ b/vecs.cc
@@ -1179,7 +1179,7 @@ assign_option(const char* module, arglist_t* ap, const char* val)
   if (case_ignore_strcmp(val, ap->argstring) == 0) {
     c = "";
   } else {
-    c = const_cast<char*>(val);
+    c = val;
   }
 
   switch (ap->argtype & ARGTYPE_TYPEMASK) {
@@ -1290,7 +1290,7 @@ find_vec(const char* vecname, const char** opts)
           if (opt) {
             found = 1;
             assign_option(svecname, ap, opt);
-            xfree(const_cast<char*>(opt));
+            xfree(opt);
             continue;
           }
         }
@@ -1347,7 +1347,7 @@ find_vec(const char* vecname, const char** opts)
           if (opt) {
             found = 1;
             assign_option(svecname, ap, opt);
-            xfree(const_cast<char*>(opt));
+            xfree(opt);
             continue;
           }
         }